package mylibrary.thread;

public class Counter {

	public static int count = 0;
	
	public synchronized static void inc() {
		try {
			Thread.sleep(1);
		} catch (Exception e) {
			e.printStackTrace();
		}
		 count++;
	}
	
	
	public static void main(String[] args) throws Exception {
		
		for(int i=0; i<1000; i++) {
			new Thread(new Runnable(){
				public void run() {
					Counter.inc();
				}
			}).start();
		}
		
		Thread.sleep(2000);
		System.out.println(Counter.count);
	}
}
